winsafe\ole\com_interfaces/
istorage.rs1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::co;
4use crate::decl::*;
5use crate::kernel::privs::*;
6use crate::ole::{privs::*, vts::*};
7use crate::prelude::*;
8
9com_interface! { IStorage: "0000000b-0000-0000-c000-000000000046";
10 }
17
18impl ole_IStorage for IStorage {}
19
20pub trait ole_IStorage: ole_IUnknown {
29 fn Commit(&self, commit_flags: co::STGC) -> HrResult<()> {
32 ok_to_hrresult(unsafe { (vt::<IStorageVT>(self).Commit)(self.ptr(), commit_flags.raw()) })
33 }
34
35 fn CopyTo(
38 &self,
39 iid_exclude: &[co::IID],
40 snb_exclude: &[impl AsRef<str>],
41 stg_dest: &impl ole_IStorage,
42 ) -> HrResult<()> {
43 ok_to_hrresult(unsafe {
44 (vt::<IStorageVT>(self).CopyTo)(
45 self.ptr(),
46 iid_exclude.len() as _,
47 vec_ptr(iid_exclude) as _,
48 SNB::from_strs(snb_exclude)?.as_ptr(),
49 stg_dest.ptr(),
50 )
51 })
52 }
53
54 #[must_use]
57 fn CreateStorage(&self, name: &str, grf_mode: co::STGM) -> HrResult<IStorage> {
58 let mut queried = unsafe { IStorage::null() };
59 ok_to_hrresult(unsafe {
60 (vt::<IStorageVT>(self).CreateStorage)(
61 self.ptr(),
62 WString::from_str(name).as_ptr(),
63 grf_mode.raw(),
64 0,
65 0,
66 queried.as_mut(),
67 )
68 })
69 .map(|_| queried)
70 }
71
72 #[must_use]
75 fn CreateStream(&self, name: &str, grf_mode: co::STGM) -> HrResult<IStream> {
76 let mut queried = unsafe { IStream::null() };
77 ok_to_hrresult(unsafe {
78 (vt::<IStorageVT>(self).CreateStream)(
79 self.ptr(),
80 WString::from_str(name).as_ptr(),
81 grf_mode.raw(),
82 0,
83 0,
84 queried.as_mut(),
85 )
86 })
87 .map(|_| queried)
88 }
89
90 fn DestroyElement(&self, name: &str) -> HrResult<()> {
93 ok_to_hrresult(unsafe {
94 (vt::<IStorageVT>(self).DestroyElement)(self.ptr(), WString::from_str(name).as_ptr())
95 })
96 }
97
98 fn MoveElementTo(
101 &self,
102 name: &str,
103 stg_dest: &impl ole_IStorage,
104 new_name: &str,
105 grf_flags: co::STGMOVE,
106 ) -> HrResult<()> {
107 ok_to_hrresult(unsafe {
108 (vt::<IStorageVT>(self).MoveElementTo)(
109 self.ptr(),
110 WString::from_str(name).as_ptr(),
111 stg_dest.ptr(),
112 WString::from_str(new_name).as_ptr(),
113 grf_flags.raw(),
114 )
115 })
116 }
117
118 #[must_use]
121 fn OpenStorage(&self, name: &str, grf_mode: co::STGM) -> HrResult<IStorage> {
122 let mut queried = unsafe { IStorage::null() };
123 ok_to_hrresult(unsafe {
124 (vt::<IStorageVT>(self).OpenStorage)(
125 self.ptr(),
126 WString::from_str(name).as_ptr(),
127 std::ptr::null_mut(),
128 grf_mode.raw(),
129 std::ptr::null_mut(),
130 0,
131 queried.as_mut(),
132 )
133 })
134 .map(|_| queried)
135 }
136
137 #[must_use]
140 fn OpenStream(&self, name: &str, grf_mode: co::STGM) -> HrResult<IStream> {
141 let mut queried = unsafe { IStream::null() };
142 ok_to_hrresult(unsafe {
143 (vt::<IStorageVT>(self).OpenStream)(
144 self.ptr(),
145 WString::from_str(name).as_ptr(),
146 std::ptr::null_mut(),
147 grf_mode.raw(),
148 0,
149 queried.as_mut(),
150 )
151 })
152 .map(|_| queried)
153 }
154
155 fn RenameElement(&self, old_name: &str, new_name: &str) -> HrResult<()> {
158 ok_to_hrresult(unsafe {
159 (vt::<IStorageVT>(self).RenameElement)(
160 self.ptr(),
161 WString::from_str(old_name).as_ptr(),
162 WString::from_str(new_name).as_ptr(),
163 )
164 })
165 }
166
167 fn_com_noparm! { Revert: IStorageVT;
168 }
171
172 fn SetClass(&self, clsid: &co::CLSID) -> HrResult<()> {
175 ok_to_hrresult(unsafe { (vt::<IStorageVT>(self).SetClass)(self.ptr(), pcvoid(clsid)) })
176 }
177
178 fn SetElementTimes(
181 &self,
182 name: Option<&str>,
183 creation: Option<&FILETIME>,
184 access: Option<&FILETIME>,
185 modification: Option<&FILETIME>,
186 ) -> HrResult<()> {
187 ok_to_hrresult(unsafe {
188 (vt::<IStorageVT>(self).SetElementTimes)(
189 self.ptr(),
190 WString::from_opt_str(name).as_ptr(),
191 pcvoid_or_null(creation),
192 pcvoid_or_null(access),
193 pcvoid_or_null(modification),
194 )
195 })
196 }
197
198 fn SetStateBits(&self, state_bits: u32, mask: u32) -> HrResult<()> {
201 ok_to_hrresult(unsafe {
202 (vt::<IStorageVT>(self).SetStateBits)(self.ptr(), state_bits, mask)
203 })
204 }
205}